package com.example.myapplication.activity.advanced_activity;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.RadioGroup;
import android.widget.TextView;

import com.example.myapplication.R;

public class RadioHorizontalActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_radio_horizontal);
        RadioGroup radioGroup = findViewById(R.id.rb_gender);
        TextView textView = findViewById(R.id.tv_result);

        radioGroup.setOnCheckedChangeListener((myGroup, id) -> {
            if (id == R.id.rb_man) {
                textView.setText("你是帅哥");
            } else {
                textView.setText("你是美女");
            }
        });
    }
}